{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="testReload"></table>
                    <!--状态显示模板-->
                    <script type="text/html" id="imgTpl">
                    <img src="{{d.user_image}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"  />
                    </script>
                    <!--操作模板-->
                    <script type="text/html" id="opeBar">
                        <a href="javascript:;" onclick="wk.layer_show('查看详情', '{:url('seeReplys')}?user_id={{d.mq_user_id}}')" class="btn btn-primary btn-xs m-r-xs" title="查看详情">查看详情</a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("meet/question")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 300]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
//                {type: 'checkbox', fixed: 'left'},
                  {type:'numbers', width: 70, title: '序号'}
                , {field: 'user_id', width: 70, title: '提问用户id', align: 'center'}
                , {field: 'user_username', width: '', title: '用户名字', align: 'center'}
                , {field: 'user_image', width: 90, title: '用户头像', align: 'center',templet: '#imgTpl'}
                , {field: 'user_phone', width: 130, title: '用户电话', align: 'center'}
                , {field: 'mq_content', width: 90, title: '提问内容', align: 'center'}
                , {field: 'mq_time', width: '', title: '提问时间', align: 'center'}
                , {fixed: 'right', width:100, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('.img-circle').viewer({
                    url: 'data-original',
                });
            }
        });
        //批量操作
        var $ = layui.$, active = {
            //批量导出订单
            excelAllT:function () {
                wk.excelAll(getIds(),$('.layui-input').serialize(),"{:url('outExcelTeam')}");
            },
            //全部导出
            excelAllNoSelectT:function () {
                wk.excelAll('all',$('.layui-input').serialize(),"{:url('outExcelTeam')}");
            }
        };
        //监听单元格编辑---排序
        table.on('edit(testReload)', function(obj){
            var value = obj.value //得到修改后的值
                ,data = obj.data //得到所在行所有键值
                ,field = obj.field; //得到字段
            wk.change(data.prod_id,"{:url('updateSort')}",field,value);
        });
        //监听状态开关操作
        form.on('switch(OnOff)', function (obj) {
            var num = '';
            obj.elem.checked == true ? num = 2: num = 1;
            //用户状态
            wk.status(this.value,num, '{:url("changeTop")}',obj);
        });
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['ct_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>